import 'package:dmz/base/pageWidget/base_stateful_widget.dart';
import 'package:dmz/base/widget/defult_widget.dart';
import 'package:dmz/base/widget/keep_alive_wrapper.dart';
import 'package:dmz/business/mine/controller/news_center_controller.dart';
import 'package:dmz/business/mine/widget/news_center_content.dart';
import 'package:dmz/business/mine/widget/news_center_widgets.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';

class NewsCenterPage extends BaseStatefulWidget<NewsCenterController> {
  const NewsCenterPage({super.key});

  @override
  String titleString() => '消息通知'.tr;

  @override
  List<Widget>? appBarActionWidget(BuildContext context) {
    return [
      DefaultText('标记全部已读'.tr, 28.sp, textColor: const Color(0xFF23C565))
          .paddingOnly(right: 32.sp)
          .addGestureDetector(
              () => controller.didAllNewsReaded(controller.selectIndex.value))
    ];
  }

  @override
  Widget buildContent(BuildContext context) {
    return Column(children: [
      Obx(() => NewsCenterWidgets.garageMainTopWidget(
          controller.selectIndex.value, controller.changeSelectPage)),
      Expanded(
          child: KeepAliveWrapper(
              child: PageView(
                  physics: const NeverScrollableScrollPhysics(),
                  controller: controller.pageController,
                  children: const [
            NewsCenteListWidget(tag: 0),
            NewsCenteListWidget(tag: 1),
            NewsCenteListWidget(tag: 2),
          ])))
    ]);
  }
}
